<template>
	<view class="page">
		<view class="applying" v-if="pageStatus!==2">
			<!-- 等待审核 -->
			<view v-if="pageStatus===1">
				<view class="img_box">
					<image :src="$util.img('upload/uniapp/community/applying.png')" mode="widthFix"></image>
					<text>您已提交城市合伙人入驻申请，请耐心等待平台审核</text>
				</view>
				<button type="primary" size="default" class="waiting-btn" @click="back">返回</button>
			</view>

			<!-- 拒绝 -->
			<view v-if="pageStatus===3">
				<view class="img_box">
					<image :src="$util.img('upload/uniapp/community/fail.png')" mode="widthFix"></image>
					<text class="errText">审核拒绝</text>
					<text class="detail">
						拒绝理由：{{err_detail || '请联系管理员'}}
					</text>
				</view>
				<button type="primary" size="default" class="waiting-btn" @click="submit_again">重新申请</button>
				<!-- <button type="primary" size="default" @click="back">返回</button> -->
			</view>
		</view>

		<view v-if="pageStatus===2">
			<view class="user-box color-base-bg">
				<view class="user-all-msg">
					<view class="user-msg">
						<image :src="$util.img(partnerInfo.headimg)" mode="aspectFill"></image>
						<view class="user-msg2">
							<text class="user-name">{{partnerInfo.name}}<text
									v-if="partnerInfo.level_name">{{partnerInfo.level_name}}</text></text>
							<text class="user-address">{{partnerInfo.address}}</text>
						</view>
					</view>

				</view>
			</view>
			<view class="float-box mar-top">
				<view class="box-item line">
					<view class="declare">
						<text
							class="declare-num">{{ (parseFloat(partnerInfo.balance) + parseFloat(partnerInfo.balance_money)).toFixed(2) }}</text>
						<text class="declare-name">可提现</text>
					</view>

					<button type="default" class="declare-btn"
						@click="$util.redirectTo('/otherpages/member/apply_withdrawal/apply_withdrawal')">申请提现</button>
				</view>
				<view class="box-item">
					<view class="declare flex-center">
						<text class="declare-num">{{partnerInfo.commission_total}}</text>
						<text class="declare-name">累计佣金(元)</text>
					</view>
					<view class="declare flex-center">
						<text class="declare-num">{{partnerInfo.balance_withdraw}}</text>
						<text class="declare-name">累计提现(元)</text>
					</view>
					<view class="declare flex-center">
						<text class="declare-num">{{partnerInfo.balance_withdraw_apply}}</text>
						<text class="declare-name">提现中(元)</text>
					</view>
				</view>
			</view>
			<view class="float-box">
				<view class="box-item line">
					<text class="title">订单概况</text>
				</view>
				<view class="box-item">
					<view class="declare flex-center">
						<text class="declare-num ">{{partnerInfo.order_complete_num}}</text>
						<view class="declare-name teli">
							<view>订笔数(笔)</view>
							<image :src="$util.img('upload/uniapp/community/explain.png')" mode=""></image>
						</view>
					</view>
					<view class="declare flex-center">
						<text class="declare-num">{{partnerInfo.day_order_count}}</text>
						<view class="declare-name teli">
							<view>今日订单(笔)</view>
							<image :src="$util.img('upload/uniapp/community/explain.png')" mode=""></image>
						</view>
					</view>
					<view class="declare flex-center">
						<text class="declare-num">{{partnerInfo.refund_order_count}}</text>
						<view class="declare-name teli">
							<view>售后订单(笔)</view>
							<image :src="$util.img('upload/uniapp/community/explain.png')" mode=""></image>
						</view>
					</view>
				</view>
			</view>
			<view class="group-box">
				<view class="group-item"
					@click="jump('/otherpages/community/community_detail/community_order?cl_id='+partnerInfo.id)">
					<image :src="$util.img('upload/uniapp/community/community_leader_icon1.png')" mode="widthFix">
					</image>
					<text class="item-name">我的订单</text>
				</view>
				<view @click="jumpCityUser" class="group-item">
					<image :src="$util.img('upload/uniapp/member/index/menu/icon7.png')" mode="widthFix">
					</image>
					<text class="item-name">我的团长</text>
				</view>
		
				<view class="group-item"
					@click="jumpCityCount">
					<image :src="$util.img('upload/uniapp/community/community_leader_icon4.png')" mode="widthFix">
					</image>
					<text class="item-name">佣金统计</text>
				</view>
				
				<view class="group-item" @click="jump('/otherpages/community/community_detail/promote_code?type=1')">
					<image :src="$util.img('upload/uniapp/community/community_leader_icon3.png')" mode="widthFix">
					</image>
					<text class="item-name">推广二维码</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageStatus: 1,
				err_detail: '',
				partnerInfo: {}
			}
		},
		onLoad() {
			this.getPartner();
		},
		methods: {
			updateTitle(status) {
				let title = '城市合伙人';
				if (status === 1) {
					title = '审核中';
				} else if (status === 1) {
					title = '审核失败';
				}
				uni.setNavigationBarTitle({
					title: title
				})
			},
			jumpCityUser(){
				uni.navigateTo({
					url:'city-user?id='+ this.partnerInfo.id
				})
			},
			jumpCityCount(){
				uni.navigateTo({
					url:'city-count?id='+ this.partnerInfo.id
				})
			},
			jump(e) {
				this.$util.redirectTo(e)
			},
			getPartner() {
				this.$api.sendRequest({
					url: '/api/member/getPartner',
					success: res => {
						console.log(res);
						this.partnerInfo = res.data.info;
						this.pageStatus = parseInt(res.data.info.status);
						this.err_detail = res.data.refuse_reason;
						this.updateTitle(this.pageStatus);
					}
				})
			},
			back() {
				this.$util.redirectTo('/pages/member/index/index')
			},
			submit_again() {
				let info = this.partnerInfo;
				uni.navigateTo({
					url: `city-partner-apply?name=${info.name}&phone=${info.phone}&email=${info.email}&address=${info.address}&remark=${info.remark}`,
				})
			}
		}
	}
</script>


<style lang="scss">
	.teli {
		height: 50rpx;
		display: flex;
		align-items: center;

		image {
			padding-top: 4rpx;
			padding-left: 6rpx;
			width: 30rpx;
			height: 30rpx;
		}
	}

	.applying {
		height: 100vh;
		background-color: #F8F8F8;

		.img_box {
			height: 70vh;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;

			image {
				width: 200rpx;
				height: 200rpx;
				margin-bottom: 70rpx;
			}

			text {
				color: $color-title;
				font-size: $font-size-base;
			}
		}

		button {
			margin: 0 auto;
			height: 80rpx;
			line-height: 80rpx;
			font-size: 32rpx;
			letter-spacing: 2rpx;
			width: 500rpx;
		}
	}


	.page {
		.user-box {
			width: 100%;
			height: 410rpx;

			.user-all-msg {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 30rpx;
				padding-top: 90rpx;

				.user-msg {
					display: flex;
					align-items: center;

					image {
						width: 108rpx;
						height: 108rpx;
						border-radius: 50%;
						border: 4rpx solid white;
					}

					.user-msg2 {
						display: flex;
						align-items: flex-start;
						flex-direction: column;
						margin-left: 12rpx;

						.user-name {
							display: flex;
							align-items: center;
							color: white;
							font-size: 32rpx;

							text {
								font-size: 24rpx;
								background-color: #F6B373;
								padding: 4rpx 20rpx;
								letter-spacing: 2rpx;
								margin-left: 10rpx;
								border-radius: 26rpx;
							}
						}

						.user-address {
							padding-top: 10rpx;
							color: white;
							font-size: 24rpx;
						}
					}
				}

				.saoma {
					color: white;
					font-size: 56rpx;
				}

				image {
					width: 40rpx;
				}
			}
		}

		.float-box {
			padding: 20rpx 30rpx;
			border-radius: 15rpx;
			margin: 0 30rpx;
			background-color: white;
			margin-top: 20rpx;

			.box-item {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.title {
					color: #303133;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
				}

				.declare {
					display: flex;
					align-items: flex-start;
					flex-direction: column;

					.declare-num {
						font-weight: 500;
						color: #303133;
						font-size: 40rpx;
					}

					.declare-name {
						color: #909399;
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 500;
					}
				}

				.flex-center {
					margin-top: 20rpx;
					align-items: center;
				}

				.declare-btn {
					margin: 0;
					width: 140rpx;
					height: 48rpx;
					line-height: 48rpx;
					padding: 0;
					background-color: #FF6706;
					color: white;
					border: none;
					font-size: 24rpx;
				}
			}

			.flex-wrap {
				flex-wrap: wrap;
			}

			.line {
				padding-bottom: 20rpx;
				border-bottom: 2rpx solid #EEEEEE;
			}
		}

		.group-box {
			border-radius: 15rpx;
			margin: 0 30rpx;
			background-color: white;
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			padding-top: 10rpx;

			.group-item {
				width: 33%;
				display: flex;
				align-items: center;
				flex-direction: column;
				justify-content: center;
				margin: 30rpx 0;

				image {
					width: 40rpx;
					margin-bottom: 10rpx;
				}

				.item-name {}
			}
		}

		.mar-top {
			margin-top: -120rpx;
		}
	}
</style>
